import React , {Component} from 'react';
import PropTypes from 'prop-types';   //校验传递的值


class Item extends Component {
	constructor(props){
		super(props)
		this.delItem = this.delItem.bind(this)
	}
	render() {
		return (
			<li >
				<span >{this.props.avname}为您服务{this.props.content}</span> 
				<button onClick={this.delItem}>删除</button>
			</li>
		)
	}
	delItem(){
		this.props.dellist(this.props.index)
	}
}

export default Item

//1.react单项数据流，传值过来的数据不能修改只能使用;
//2.函数式编程

Item.propTypes={
	avname:PropTypes.string.isRequired,
	content:PropTypes.string,
	index:PropTypes.number,
	dellist:PropTypes.func,
}

Item.defaultProps = {
	avname:'天海翼'
}